package com.gagakuai.engine.impl.bpmn.behavor;

import com.gagakuai.engine.exception.ActivitiException;
import com.gagakuai.engine.impl.delegate.ActivityExecution;
import com.gagakuai.engine.impl.pvm.delegate.SignallableActivityBehavior;

/*
 * @program: common-starters
 * @description: 作为三大元素行为类的基类
 * @author: houhong
 * @create: 2023-01-02 20:54
 */
public abstract class FlowNodeActivityBehavior implements SignallableActivityBehavior {

    protected BpmnActivityBehavior bpmnActivityBehavior = new BpmnActivityBehavior();

    @Override
    public void execute(ActivityExecution execution) throws Exception {

        leave(execution);
    }

    /*
     * 离开当前活动
     */
    protected void leave(ActivityExecution execution)  {
        //执行默认的出线
        bpmnActivityBehavior.performDefaultOutgoingBehavior(execution);
    }

    @Override
    public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
        // concrete activity behaviours that do accept signals should override this method;
        throw new ActivitiException("this activity doesn't accept signals");
    }
}